package net.qiqbframework.commandhandling;

import javax.annotation.Nonnull;


public class WrappedCommandCallback<C, R> implements CommandCallback<C, R> {

    private final CommandCallback<C, R> outerCallback;
    private final CommandCallback<C, R> innerCallback;

    protected WrappedCommandCallback(CommandCallback<C, R> outerCallback, CommandCallback<C, R> innerCallback) {
        this.outerCallback = outerCallback;
        this.innerCallback = innerCallback;
    }

    @Override
    public void onResult(@Nonnull CommandMessage<? extends C> commandMessage, @Nonnull CommandResultMessage<? extends R> commandResultMessage) {
        outerCallback.onResult(commandMessage, commandResultMessage);
        innerCallback.onResult(commandMessage, commandResultMessage);
    }
}
